package com.the8thfold.anton.ant

import com.the8thfold.anton.users.User
import grails.plugin.multitenant.core.groovy.compiler.MultiTenant

@MultiTenant
class AntJob {

    static constraints = {
        runResults nullable: true
        propertyValues nullable: true
        targets nullable: true
        users nullable: true
        schedule nullable: true
    }

    static belongsTo = [script:AntScript]
    static transients = ['active']
    static hasMany = [
            runResults:AntJobRunResults,
            propertyValues:AntJobPropertyValue,
            targets:AntJobTarget,
            users:AntJobUser
    ]

    String jobId
    String name
    String description
    Date dateCreated
    User createdBy
    JobStatus jobStatus
    String schedule

    public boolean isActive(){
        return JobStatus.ACTIVE.equals(jobStatus)
    }
}

enum JobStatus {
    ACTIVE, PAUSED
}
